<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BookingGuests
 *
 * @author fabiano
 */
class BookingGuests {
    //put your code here
    
    public $booking_guest_id;
    public $booking_detail_id;
    public $booking_room_id;
    public $guest_first_name;
    public $guest_tittle;
    public $guest_last_name;
    public $guest_age;
    public $guest_type;
    
    function __construct($params = NULL) {
        
        if ($params != NULL){
            $this->setBooking_detail_id($params['booking_detail_id']);
            $this->setBooking_guest_id($params['booking_guest_id']);
            $this->setBooking_room_id($params['booking_room_id']);
            $this->setGuest_age($params['guest_age']);
            $this->setGuest_first_name($params['guest_first_name']);
            $this->setGuest_last_name($params['guest_last_name']);
            $this->setGuest_tittle($params['guest_tittle']);
            $this->setGuest_type($params['guest_type']);            
        }
        
    }

    
    public function getBooking_guest_id() {
        return $this->booking_guest_id;
    }

    public function setBooking_guest_id($booking_guest_id) {
        $this->booking_guest_id = $booking_guest_id;
    }

    public function getBooking_detail_id() {
        return $this->booking_detail_id;
    }

    public function setBooking_detail_id($booking_detail_id) {
        $this->booking_detail_id = $booking_detail_id;
    }

    public function getBooking_room_id() {
        return $this->booking_room_id;
    }

    public function setBooking_room_id($booking_room_id) {
        $this->booking_room_id = $booking_room_id;
    }

    public function getGuest_first_name() {
        return $this->guest_first_name;
    }

    public function setGuest_first_name($guest_first_name) {
        $this->guest_first_name = $guest_first_name;
    }

    public function getGuest_tittle() {
        return $this->guest_tittle;
    }

    public function setGuest_tittle($guest_tittle) {
        $this->guest_tittle = $guest_tittle;
    }

    public function getGuest_last_name() {
        return $this->guest_last_name;
    }

    public function setGuest_last_name($guest_last_name) {
        $this->guest_last_name = $guest_last_name;
    }

    public function getGuest_age() {
        return $this->guest_age;
    }

    public function setGuest_age($guest_age) {
        $this->guest_age = $guest_age;
    }

    public function getGuest_type() {
        return $this->guest_type;
    }

    public function setGuest_type($guest_type) {
        $this->guest_type = $guest_type;
    }
    
    public function save(){
        
        $sql = "INSERT INTO booking_guests SET ".make_set_clause(objectToArray($this));  
        error_log("[BookingGuests.class] - save " .$sql);
        $result = mysql_query($sql) or die (mysql_error());
        $this->booking_guest_id = mysql_insert_id();  
    }
    
    public function get_guests_by_booking_detail_id($booking_detail_id){
	if(!empty($booking_detail_id)){		
	   $sql = "select 
                        booking_detail_id,
                        booking_room_id,
                        guest_tittle,
                        guest_first_name,
                        guest_last_name,
                        guest_age,
                        guest_type
                   from 
                        booking_guests 
                   where booking_detail_id = ".$booking_detail_id;	
           error_log("query: ".$sql);
	   return apply_query($sql);
        } 
          else return null;        
    }
    
    
}

?>
